﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EzDesk.Apps.ServiceImpl.Attendance.Repositories.Interface;
using EzDesk.Apps.Model.Attendance;

namespace EzDesk.Apps.ServiceImpl.Attendance.Repositories
{
    public partial class EvaluationModifyApplicationRepository : IEvaluationModifyApplicationRepository
    {
        public IList<EvaluationModifyApplicaiton> GetModifyEvaluationApplicationByUserAndDate(Guid userId, DateTime date)
        {
            return GetAll()
                .Where(p => p.ApplyUserId == userId && p.Date == date.Date)
                .ToList();
        }

        public void SetFeedIdToEvaluationApplication(Guid userId, DateTime date, Guid feedId)
        {
            var application = GetAll().FirstOrDefault(p => p.ApplyUserId == userId && p.Date == date.Date);
            if (application!= null)
            {
                application.FeedId = feedId;
            }
            Update(application, true);
        }
    }
}
